<template>
  <a-modal
    :visible="visible"
    :title="$t('key.shlw')"
    :width="600"
    :okText="$t('button.SubmitReview')"
    :confirmLoading="confirmLoading"
    @cancel="() => { $emit('cancel') }"
    @ok="confirm"
  >
    <p v-for="(i, index) in data" :key="index">{{ `${i.xh}: ${i.xm}` }}</p>
    <a-form :form="form">
      <a-row>
        <a-col :md="10" :sm="24">
         <a-form-item
            :label="$t('key.reviewResult')"
            :labelCol="{span: 9}"
            :wrapperCol="{span: 14, offset: 1}"
          >
            <a-select  v-decorator="[
              'statusCode',
              {
                rules: [{ required: true, message: '请选择审核结果!' }],
              }
            ]" allowClear>
              <template v-for="i in TYPE0124">
                <a-select-option v-if="i.code !== '01'" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </template>
            </a-select>
          </a-form-item>
        </a-col>
      </a-row>
      <a-form-item :label="$t('key.note')" :labelCol="{span: 3}" :wrapperCol="{span: 12, offset: 1}">
        <a-input type="textarea" v-decorator="['explain']" :autosize="{ minRows: 2, maxRows: 6 }"/>
      </a-form-item>
    </a-form>
  </a-modal>

</template>

<script>
import { mapState } from 'vuex'

export default {
  props: ['visible', 'id', 'data'],
  data () {
    return {
      form: this.$form.createForm(this),
      detail: {},
      tableData: [],
      confirmLoading: false
    }
  },
  computed: {
    ...mapState({
      TYPE0124: state => state.app['TYPE0124']
    })
  },
  created () {
    this.$store.dispatch('app/setDictionary', 'TYPE0124')
  },
  methods: {
    confirm () {
      this.form.validateFields((err, values) => {
        if (err) return
        this.confirmLoading = true
        let xh = []
        xh = this.data.map(i => i.xh)
        this.$api.student.supplementCheck({...values, xh, explain: values.explain || ''}).then(res => {
          this.$message.success(res.msg)
          this.$emit('cancel')
          this.$emit('refresh')
          this.confirmLoading = false
        })
      })
    }
  }
}
</script>

<style>

</style>
